package com.share.design.composite.tree;

/**
 * @author caifan
 * @since 2022/10/30
 */
public class Leaf extends AbstractNode{

    private int id;
    private int pid;

    @Override
    public boolean isRoot() {
        return false;
    }

    @Override
    public int getId() {
        return this.id;
    }

    @Override
    public int getParentId() {
        return this.pid;
    }

    @Override
    public void setId(int id) {
        this.id = id;
    }

    @Override
    public void setParentId(int parentId) {
        this.pid = parentId;
    }

    @Override
    public void add(AbstractNode abstractNode) {
        throw new UnsupportedOperationException("叶子节点不允许添加");
    }

    @Override
    public void remove(AbstractNode g) {
        throw new UnsupportedOperationException("叶子节点不允许删除");
    }

    @Override
    public AbstractNode getChild(int i) {
        return null;
    }
}
